package com.example.mrwang.paintcircu;

import android.app.Activity;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;

import java.util.Timer;
import java.util.TimerTask;

public class MainActivity extends Activity {
    RoundProgressBar mBar;
    Timer timer;
    public final Handler handler=new Handler(){
        @Override
        public void handleMessage(Message msg) {
            mBar.setProgress(msg.arg1);
            Log.d("timer", "handleMessage: ");
            if(msg.arg1==90){
                timer.cancel();
            }
        }
    };
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mBar= (RoundProgressBar) findViewById(R.id.bar);
        mBar.setMaxStep(100);

        timer = new Timer();
        timer.schedule(new TimerTask() {
            int i = 0;

            @Override
            public void run() {
                i++;
                Message obtain = Message.obtain();
                obtain.arg1 = i;
                handler.sendMessage(obtain);
            }
        }, 0, 20);

    }
}
